﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Manage_Emp_play : AdminPageBase
{
    int classDetailId;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["sc"] != null)
        {
              classDetailId =Convert.ToInt32( Request.QueryString["sc"].ToString());
               DataSet ds = jtDataAccess.GetList("ClassDetail", "ClassDetailId=" + classDetailId, "ClassDetailId");
               if (CoreTools.CheckDataSet(ds))
               {
                   string url = ds.Tables[0].Rows[0]["Url"].ToString();
                   if (url != null && url != "")
                   {
                       lblPlay.ForeColor = System.Drawing.Color.Red;
                       string playurl = ConfigHelper.VideoUploadPath.Replace("~/", "../../");
                       string extensionName = System.IO.Path.GetExtension(url);
                       string ClassResourceType = "";
                       ClassResourceType = CoreTools.GetClassResourceType(extensionName.ToLower());
                       if (ClassResourceType.Equals("swf"))
                       {
                           System.IO.FileInfo file = new System.IO.FileInfo(HttpContext.Current.Request.MapPath(ConfigHelper.VideoUploadPath.Replace("~/", "../../") + url));
                           if (file.Exists)
                           {
                               lblPlay.Text = Play.TVCPlayer("100%", "100%", playurl + url);
                           }
                           else
                           {
                               lblPlay.Text = "课程资源文件无法找到!";
                           }
                       }
                       else if (ClassResourceType.Equals("video"))
                       {
                           System.IO.FileInfo file = new System.IO.FileInfo(HttpContext.Current.Request.MapPath(ConfigHelper.VideoUploadPath.Replace("~/", "../../") + url));
                           if (file.Exists)
                           {
                               lblPlay.Text = Play.MediaPlayer("100%", "100%", playurl + url);
                           }
                           else
                           {
                               lblPlay.Text = "课程资源文件无法找到!";
                           }
                       }
                       else if (ClassResourceType.Equals("officeDocument"))
                       {
                           string fpath = ConfigHelper.SWFFilePath.Replace("~/", "../../") + url.Replace(extensionName, ".swf");
                           string path = HttpContext.Current.Request.MapPath(ConfigHelper.SWFFilePath.Replace("~/", "../../") + url.Replace(extensionName, ".swf"));
                           System.IO.FileInfo file = new System.IO.FileInfo(path);

                           if (file.Exists)
                           {
                               lblPlay.Text = Play.FlexPaperViewer(0, 0, fpath);
                           }
                           else
                           {
                               lblPlay.Text = "课程资源文件无法找到!";
                           }

                       }
                       else if (ClassResourceType.Equals("Image"))
                       {
                           System.IO.FileInfo file = new System.IO.FileInfo(HttpContext.Current.Request.MapPath(ConfigHelper.ImgUploadPath.Replace("~/", "../../") + url));
                           if (file.Exists)
                           {
                               lblPlay.Text = "<img src=" + ConfigHelper.ImgUploadPath.Replace("~/", "../../") + url + ">";
                           }
                           else
                           {
                               lblPlay.Text = "课程资源文件无法找到!";
                           }
                       }
                   }
                   else
                       lblPlay.Text = "课程资源文件无法找到!";
               }
               else
                   lblPlay.Text = "课程资源文件无法找到!";

        }
        
    }
}